#pragma once
#include <iostream>
#include <pthread.h>
#include "Lock.hpp"

namespace CondModule
{
    class Cond
    {
    public:
        Cond(const Cond&) = delete;
        Cond& operator=(Cond&) = delete;
        Cond()
        {
            pthread_cond_init(&_cond, nullptr);
        }

        void Wait(MutexModule::Mutex& mutex)
        {
            pthread_cond_wait(&_cond, mutex.GetPointer());
        }

        void Signal()
        {
            pthread_cond_signal(&_cond);
        }

        void Broadcast()
        {
            pthread_cond_broadcast(&_cond);
        }

        ~Cond()
        {
            pthread_cond_destroy(&_cond);
        }
    private:
        pthread_cond_t _cond;
    };
}